package com.sales.entity;

import com.sales.enums.UserTypeEnums;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.LastModifiedDate;

import javax.persistence.*;
import java.util.Date;

/**
 * Created by lihu on 2017/9/7.
 */
@Data
@Entity
@NoArgsConstructor
@AllArgsConstructor
public class Profile {

    @Id
    @Column(length = 50)
    private String id;

    //关联账号
    private String username;

    //姓名
    private String name;

    //身份证号
    private String idCardNo;

    //银行卡号
    private String bankCardNo;

    //银行名称
    private String bankName;

    //账号类型
    @Enumerated(EnumType.STRING)
    private UserTypeEnums userTypeEnums;

    //子账号数量
    private Integer codeCount = 0;

    //推广店铺数（包含子级推广）
    private int storeCount = 0;

    //关联上级用户账号
    private String parentUserName;

    //对应邀请码
    private String referralCode;

    private boolean enabled = true;

    private int count;

    @CreatedBy
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3)")
    private Date addTime;

    @LastModifiedDate
    @Column(insertable = false, updatable = false, columnDefinition = "TIMESTAMP(3) DEFAULT CURRENT_TIMESTAMP(3) ON UPDATE CURRENT_TIMESTAMP(3)")
    private Date updateTime;

    public Profile(String id, String referralCode) {
        this.id = id;
        this.referralCode = referralCode;
    }
}
